var checkOut = new Vue({
    el:'#checkOut',
    data:{
        reletRoomNum:'',
        preDay:'',
        perpay:'',
        pay:'',
        repay:'',
        overRoomNum:'',
        clearing:'',
        roomNum:'',
        name:'',
        orderId:'',
        uncheckedList:[]
    },
    methods:{
        detection:function(){
            $.ajax({
                url:'detection',
                type:'POST',
                cache:false,
                dataType:'json',
                data:{
                    'reletRoomNum':this.reletRoomNum,
                    'preDay':this.preDay
                },
                success:function(data){
                    if(data.status == "error"){
                        alert(data.info);
                        return;
                    }
                    checkOut.perpay=data.info;
                },
                error:function(){
                    alert("请刷新网络")
                }
            })
        },
        relet:function(){
            $.ajax({
                url:'relet',
                type:'POST',
                cache:false,
                dataType:'json',
                data:{
                    'prepay':this.pay,
                    'reletRoomNum':this.reletRoomNum,
                    'preDay':this.preDay
                },
                success:function(data){
                    alert(data.info);
                },
                error:function(){
                    alert("请刷新网络")
                }
            })
        },
        settleAccounts:function(){
            $.ajax({
                url:'settleAccounts',
                type:'POST',
                cache:false,
                dataType:'json',
                data:{
                    'overRoomNum':this.overRoomNum
                },
                success:function(data){
                    if(data.status == "error"){
                        alert(data.info);
                        return;
                    }
                    checkOut.repay = data.info;
                },
                error:function(){
                    alert("请刷新网络")
                }
            })
        },
        uncheckByRoomNum:function(){
            $.ajax({
                url:'select_unchecked',
                type:'POST',
                dataType:'json',
                cache:false,
                data:{
                    'roomNum':this.roomNum
                },
                success:function(data){
                    if(data.status == "error"){
                        alert(data.info);
                        return;
                    }
                    var uncheckDtos = data.info;
                    if(uncheckDtos.length == 0){
                        alert("搜索为空")
                    }
                    checkOut.uncheckedList = [];
                    for(var i=0;i<uncheckDtos.length;i++){
                        checkOut.uncheckedList.push({
                            orderId:uncheckDtos[i].orderId,
                            roomNum:uncheckDtos[i].roomNum,
                            name:uncheckDtos[i].name,
                            identity:uncheckDtos[i].identity,
                            telephone:uncheckDtos[i].telephone,
                            money:uncheckDtos[i].money
                        });
                    }
                },
                error:function(){
                    alert("请刷新网络")
                }
            })

        },
        uncheckByName:function(){
            $.ajax({
                url:'select_unchecked',
                type:'POST',
                dataType:'json',
                cache:false,
                data:{
                    'name':this.name
                },
                success:function (data) {
                    if(data.status == "error"){
                        alert(data.info);
                        return;
                    }
                    var uncheckDtos = data.info;
                    checkOut.uncheckedList = [];
                    if(uncheckDtos.length == 0){
                        alert("搜索为空")
                    }
                    for(var i=0;i<uncheckDtos.length;i++){
                        checkOut.uncheckedList.push({
                            orderId:uncheckDtos[i].orderId,
                            roomNum:uncheckDtos[i].roomNum,
                            name:uncheckDtos[i].name,
                            identity:uncheckDtos[i].identity,
                            telephone:uncheckDtos[i].telephone,
                            money:uncheckDtos[i].money
                        });
                    }
                },
                error:function(){
                    alert("请刷新网络")
                }
            })

        },
        finishUncheck:function () {
            $.ajax({
                url:'finish_unchecked',
                type:'POST',
                dataType:'json',
                cache:false,
                data:{
                    'orderId':this.orderId
                },
                success:function (data) {
                    if(data.status == "error"){
                        alert(data.info);
                        return;
                    }
                    checkOut.clearing = data.info;
                },
                error:function(){
                    alert("请刷新网络")
                }
            })
        }
        
    }
})